<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body style="display: none">
<?php
include "connection.php";




$product_week = $_REQUEST['product_day'];
$product_month = $_REQUEST['product_month'];





for($i=0;$i<30;$i++)
{


echo $product_at = substr($_REQUEST['product_at_'.$i],0,1);
echo "<br/>";

unset($zc);
unset($wc);
unset($wwnc);

    $product_status = $_REQUEST['status'.$i];


    $zc = explode("/",$_REQUEST['zc_product_name_'.$i]); //获取早餐 和 分离价钱
    $wc = explode("/",$_REQUEST['wc_product_name_'.$i]);
    $wwnc = explode("/",$_REQUEST['wanc_product_name_'.$i]);





    print_r($zc);
    echo "<br/>";


    switch($product_at){
        case 1:
            echo $product_name = $zc[0];
            echo $product_price = str_replace("元","",$zc[1]);
            break;
        case 2:
            $product_name = $wc[0];
            $product_price = str_replace("元","",$wc[1]);
            break;
        case 3:
            $product_name = $wwnc[0];
            $product_price = str_replace("元","",$wwnc[1]);
            break;
        default:
            break;
    }









    $product_new_price = $_REQUEST['new_price_'.$i];  //接受新价钱值

    if(is_numeric($product_new_price)){  //判断如果输入了新价钱，就写入新价钱
        $product_price = $product_new_price;

        $tabledishes = "dishes";
        $sql = "insert into $tabledishes (
product_name,
price,
at,
publish
) value (
'$product_name',
'$product_price',
'$product_at',
'1'
)";




        $query = mysql_query($sql) or die ("添加失败，请返回！");
    }






    $tableProduct = "product";
    echo "<br/>";

echo $sql = "insert into $tableProduct (
product_name,
price,
week,
month,
status,
at
) value (
'$product_name',
'$product_price',
'$product_week',
'$product_month',
'$product_status',
'$product_at'
)";


if($product_name){
$query = mysql_query($sql) or die ("添加失败，请返回！");
    echo "添加成功";

}

    echo "<br/>";

}



?>
<script type="text/javascript">
    alert("菜式已添加，请点击返回列表！");
    document.location = "../controlbase/menu/admin_productset.php";
</script>
</body>
</html>